#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
const int maxn = 1e6+10;
int prime[maxn]={1,1,0};
void init()
{
	for(int i = 2;i*i<=maxn;i++)
	{
		if(!prime[i])
		{
			for(int j = i*i;j<=maxn;j =j+i)
			{
				//printf("%d\n",j);
				prime[j] = 1;
			}
		}
	}
}
int main()
{
	int n;
	init();
	cin>>n;
	for(int i = 0;i<n;i++)
	{
		long long x;
		cin>>x;
		long long t = sqrt(x);
		//cout<<prime[6]<<endl;
		if(t*t==x&&!prime[t]) printf("YES\n");
		else printf("NO\n");
	}
}
